package com.xxwy.dependency.injection.setting;

import com.xxwy.dependency.UserHold;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * @author wy
 * @date 2020/4/26 15:10
 */
public class AutoWiringByNameDependencySettingInjectionDemo {

  public static void main(String[] args) {

    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader definitionReader = new XmlBeanDefinitionReader(beanFactory);
    int definitions = definitionReader.loadBeanDefinitions("classpath:/META-INF/dependency-injection-set.xml");

    /**
     * - 手动
     * - byName / byType
     * <bean id="hold" class="com.xxwy.dependency.UserHold"
     *     autowire="byType">
     *
     * @return
     */
    UserHold bean = beanFactory.getBean(UserHold.class);
    System.out.println(bean);
  }
}
